package java_generics.bounded_type_parameters;

public class NumberClass<T extends Number> {
	T[] inputArray;
	public NumberClass(T[] inputArray) {
		this.inputArray = inputArray;
	}
	public Double sum() {
		Double sum = 0.0;

		for (T t : inputArray) {
			sum = sum + t.doubleValue();
		}

		return sum;
	}
	public static void main(String args[]) {
		
		Integer[] intArray = {1,2,3,4,5};
		Double[] doubleArray = {1.0,2.0,3.0,4.0,5.0};
		
		new NumberClass<Integer>(intArray).sum();
		new NumberClass<Double>(doubleArray).sum();
	}
}
